'''
作者：命运的左轮
blog：https://fate-zuolun.blog.csdn.net/
'''

def gcd(a,b):
    # 边界条件
    if a % b == 0:
        return b
    # 辗转相除法
    return gcd(b,a%b)


if __name__ == '__main__':
    res = 0
    for i in range(1,2021):
        for j in range(1,2021):
            if gcd(i,j) == 1:
                res+=1
    print(res)